/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
export default function access(initialState: { currentUser?: any | undefined }) {
  const { currentUser } = initialState || {};
  return {
    role: currentUser && currentUser.role,
    canDispatchOrder: currentUser && (currentUser.role === 'dispatch_user' || currentUser.role === 'admin' || currentUser.role == 'super_admin'),
    isUser: currentUser && (currentUser.role === 'admin' || currentUser.role == 'super_admin' || currentUser.role === 'user'),
    isAdmin: currentUser && (currentUser.role === 'admin' || currentUser.role == 'super_admin'),
    isSuperAdmin: currentUser && currentUser.role === 'super_admin',
  };
}
